package com.xrui.rts.utillity

import scala.util.hashing.MurmurHash3

object HashString {
    def getHashBytes(str: String): Array[Byte] = {
        getHashBytes(MurmurHash3.stringHash(str))
    }

    def getHashBytes(hash: Long): Array[Byte] = {
        val hashArray = "%08x".format(hash.toInt).toCharArray.map(_.toByte)
        size match {
            case _ if size < 8 => hashArray.slice(0, size)
            case _ => hashArray
        }
    }

    def size: Int = 8
}
